<template>
  <!-- 门店管理-门店设置（列表） -->
  <div class="mod-seckill-shopAuditing">
    <div class="search-bar">
      <el-form
        @submit.native.prevent
        :inline="true"
        ref="searchForm"
        :model="searchForm"
        size="small"
        :class="
          this.$i18n.t('language') === 'English'
            ? 'en-search-form'
            : 'zh-search-form'
        "
      >
        <div class="input-row">
          <el-form-item
            prop="shopName"
            :label="$t('outlet.outletName') + ':'"
          >
            <el-input
              v-model="searchForm.shopName"
              size="small"
              :placeholder="$t('outlet.outletName')"
            ></el-input>
          </el-form-item>

          <el-form-item :label="$t('outlet.outletId') + ':'">
            <el-input
              v-model="searchForm.shopCode"
              size="small"
              :placeholder="$t('tip.input')"
            ></el-input>
          </el-form-item>

          <el-form-item :label="$t('coupon.brandName') + ':'">
            <el-input
              v-model="searchForm.brandName"
              size="small"
              :placeholder="$t('tip.input')"
            ></el-input>
          </el-form-item>

          <el-form-item :label="$t('outlet.brandTagId') + ':'">
            <!-- <el-input
              v-model="searchForm.brandTagName"
              size="small"
              :placeholder="$t('tip.input')"
            ></el-input> -->

            <el-select
              clearable
              filterable
              v-model="searchForm.brandTagName"
              :placeholder="$t('tip.select')"
            >
              <el-option
                v-for="item in allBrandList"
                :key="item.id"
                :label="item.name"
                :value="item.name"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item
            prop="shopAppName"
            :label="$t('outlet.shopAppName') + ':'"
          >
            <el-input
              v-model="searchForm.shopAppName"
              size="small"
              :placeholder="$t('tip.input')"
            ></el-input>
          </el-form-item>

          <el-form-item
            prop="type"
            :label="'门店优选' + ':'"
          >
            <el-select
              clearable
              v-model="searchForm.type"
              placeholder="门店优选"
            >
              <el-option
                :label="$t('outlet.generalStores')"
                :value="0"
              ></el-option>
              <el-option
                :label="$t('outlet.optimization')"
                :value="1"
              ></el-option>
            </el-select>
          </el-form-item>
          <!-- 状态shopProcessStatus(-1, "开店申请未通过" 0, "开店申请待审核" 1, "停业中" 2, "营业中" 3, "门店下线" 4, "门店下线待审核" 5, "平台下线" 6, "平台下线待审核")  -->

          <template v-if="unreview">
            <el-form-item
              prop="shopProcessStatus"
              :label="$t('distributionMsg.auditStatus') + ':'"
            >
              <el-select
                clearable
                v-model="searchForm.shopProcessStatus"
                :placeholder="$t('distributionMsg.auditStatus')"
              >
                <el-option
                  :label="$t('liveRoom.auditFailed')"
                  :value="-1"
                ></el-option>
                <el-option
                  :label="
                    $t('shopProcess.storeOpeningApplicationPendingReview')
                  "
                  :value="0"
                ></el-option>
                <!-- <el-option :label="$t('brand.closed')" :value="1"></el-option> -->
                <!-- <el-option
                  :label="$t('brand.inOperation')"
                  :value="2"
                ></el-option> -->
                <!-- <el-option
                  :label="$t('brand.brandOffline')"
                  :value="3"
                ></el-option> -->
                <el-option
                  :label="$t('brand.brandOfflineToBeReviewed')"
                  :value="4"
                ></el-option>
                <!-- <el-option
                  :label="$t('brand.platformOffline')"
                  :value="5"
                ></el-option> -->
                <el-option
                  :label="$t('brand.platformOfflineToBeReviewed')"
                  :value="6"
                ></el-option>
              </el-select>
            </el-form-item>
          </template>

          <template v-if="!unreview">
            <el-form-item
              prop="shopProcessStatus"
              :label="$t('outlet.outletStatus') + ':'"
            >
              <el-select
                clearable
                v-model="searchForm.shopProcessStatus"
                :placeholder="$t('outlet.outletStatus')"
              >
                <el-option
                  :label="$t('brand.closed')"
                  :value="1"
                ></el-option>
                <el-option
                  :label="$t('brand.inOperation')"
                  :value="2"
                ></el-option>
                <el-option
                  :label="$t('brand.brandOffline')"
                  :value="3"
                ></el-option>
                <!-- <el-option
                  :label="$t('brand.brandOfflineToBeReviewed')"
                  :value="4"
                ></el-option> -->
                <el-option
                  :label="$t('brand.platformOffline')"
                  :value="5"
                ></el-option>
                <!-- <el-option
                  :label="$t('brand.platformOfflineToBeReviewed')"
                  :value="6"
                ></el-option> -->
              </el-select>
            </el-form-item>
            <el-form-item
              prop="shopShowingType"
              :label="$t('outlet.shopShowingType') + ':'"
            >
              <el-select
                clearable
                v-model="searchForm.shopShowingType"
                :placeholder="$t('outlet.shopShowingType')"
              >
                <el-option
                  :label="$t('outlet.showingType0')"
                  :value="1"
                ></el-option>
                <el-option
                  :label="$t('outlet.showingType1')"
                  :value="2"
                ></el-option>
                <el-option
                  :label="$t('outlet.showingType2')"
                  :value="3"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              prop="tableTop"
              :label="'餐边码状态' + ':'"
            >
              <el-select
                clearable
                v-model="searchForm.tableTop"
                placeholder="餐边码状态"
              >
                <el-option
                  label="启用中"
                  value="OPEN"
                ></el-option>
                <el-option
                  label="已停用"
                  value="CLOSE"
                ></el-option>

              </el-select>
            </el-form-item>
          </template>

          <template v-if="unreview">
            <el-form-item
              :label="$t('brand.applicationTime') + ':'"
              label-width="70px"
            >
              <el-date-picker
                v-model="dateRange"
                @change="changeDateRange"
                type="datetimerange"
                :range-separator="$t('coupon.to')"
                value-format="yyyy-MM-dd HH:mm:ss"
                :start-placeholder="$t('coupon.startTime')"
                :end-placeholder="$t('coupon.endTime')"
              ></el-date-picker>
            </el-form-item>
          </template>

          <!-- 配送方式 -->
          <!-- <el-form-item
            prop="shopProcessStatus"
            :label="$t('product.delType') + ':'"
          >
            <el-select
              clearable
              v-model="searchForm.dvyType"
              :placeholder="$t('product.delType')"
            >
              <el-option v-for="item in dvyType" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item style="float: right">
            <div
              class="default-btn primary-btn"
              @click="searchChange(true)"
            >
              {{ $t("product.search") }}
            </div>
            <div
              class="default-btn"
              @click="resetSearchForm('searchForm')"
            >
              {{ $t("product.reset") }}
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <el-button
      class="confirm-btn"
      type="primary"
      size="small"
      @click="newStore"
    >{{ $t("brand.newStore") }}</el-button>
    <el-button
      class="confirm-btn"
      plain
      type="danger"
      size="small"
      @click="closeAllTableTop"
    >停用所有餐边码</el-button>
    <el-button
      class="confirm-btn"
      type="primary"
      size="small"
      @click="openAllTableTop"
    >启用所有餐边码</el-button>
    <div class="main-container">
      <!-- <div class="operation-bar">
        <div
          v-if="isAuth('platform:station:addOutlet')"
          class="default-btn primary-btn"
          @click="insertShop()"
        >
          {{ $t("crud.addTitle") }}
        </div>
      </div> -->
      <div class="table-con audit-shop-table">
        <div
          v-if="dataList.length === 0"
          class="empty-text"
        >
          {{ $t("user.noData") }}
        </div>
        <el-table
          :key="tabValue"
          ref="auditShop"
          :data="dataList"
          header-cell-class-name="table-header"
          row-class-name="table-row"
          style="width: 100%"
        >
          <!-- <el-table-column
            align="center"
            prop="type"
            :label="$t('brand.brandLogo')"
            width="auto"
          >
            <template slot-scope="scope">
              <img
                :src="getImgSrc(scope.row.shopLogo)"
                :alt="scope.row.prodName"
                style="width: 60px; height: 60px"
                @error="handlePicError"
              />
            </template>
          </el-table-column> -->
          <!-- 序号 -->
          <el-table-column
            align="center"
            :label="$t('formData.serialNumber')"
            type="index"
            width="120"
            fixed="left"
          >
            <template slot-scope="scope">
              <span>{{
                (page.currentPage - 1) * page.pageSize + scope.$index + 1
              }}</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            fixed="left"
            :label="$t('outlet.outletId')"
            prop="shopCode"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="type"
            label="门店优选"
            width="auto"
          >
            <template slot-scope="scope">
              <span class="tag-text">{{
                [$t("outlet.generalStores"), $t("outlet.optimization")][
                  scope.row.type
                ]
              }}</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            fixed="left"
            :label="$t('outlet.shopLogo')"
            width="120px"
          >
            <template slot-scope="scope">
              <img
                :src="getImgSrc(scope.row.shopLogo)"
                :alt="scope.row.prodName"
                style="width: 60px; height: 60px"
                @error="handlePicError"
              />
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="shopName"
            fixed="left"
            :label="$t('outlet.outletName')"
            width="120px"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="shopAppName"
            :label="$t('outlet.shopAppName')"
            fixed="left"
            width="200"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="brandName"
            :label="$t('shopProcess.brandName')"
            width="200"
          >
          </el-table-column>

          <!--  <el-table-column
            align="center"
            prop="brandTagName"
            :label="$t('outlet.brandTagId')"
            width="200"
          >
            <template slot-scope="scope">
              <img
                :src="getImgSrc(scope.row.brandTagName)"
                :alt="scope.row.prodName"
                style="width: 60px; height: 60px"
                @error="handlePicError"
              />
            </template>
          </el-table-column> -->

          <el-table-column
            align="center"
            prop="shopAddress"
            :label="$t('o2oBrand.storeLocation')"
            width="200"
            show-overflow-tooltip
          >
          </el-table-column>

          <!-- <el-table-column
            align="center"
            prop="type"
            :label="$t('sys.creationTime')"
            width="auto"
          >
            <template slot-scope="scope">
              <span class="tag-text">{{ scope.row.createTime }}</span>
            </template>
          </el-table-column> -->

          <el-table-column
            align="center"
            prop="type"
            :label="$t('outlet.shopShowingType')"
            width="100"
          >
            <template slot-scope="scope">
              <span class="tag-text">
                {{
                  [
                    "",
                    $t("outlet.showingType0"),
                    $t("outlet.showingType1"),
                    $t("outlet.showingType2"),
                  ][scope.row.shopShowingType]
                }}
              </span>
            </template>
          </el-table-column>

          <!--  -->
          <!--  -->
          <!--  -->
          <!-- <el-table-column
            align="center"
            prop="type"
            label="业态中类"
            width="auto"
          >
            <template slot-scope="scope">
              <span class="tag-text">--</span>
            </template>
          </el-table-column> -->

          <!-- <el-table-column
            align="center"
            prop="type"
            label="营业时间"
            width="auto"
          >
            <template slot-scope="scope">
              <span class="tag-text">{{ scope.row.openTime }} ~ {{convertTimeFormat(scope.row.closeTime)}}</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="type"
            label="配送方式"
            width="auto"
          >
            <template slot-scope="scope">
              <span class="tag-text">--</span>
            </template>
          </el-table-column> -->

          <!--  -->
          <!--  -->
          <!--  -->

          <!-- <el-table-column
            align="center"
            prop="createTime"
            :label="$t('outlet.applicationDate')"
            min-width="100"
          >
          </el-table-column> -->
          <!-- 状态shopProcessStatus(-1, "开店申请未通过" 0, "开店申请待审核" 1, "停业中" 2, "营业中" 3, "门店下线" 4, "门店下线待审核" 5, "平台下线" 6, "平台下线待审核")  -->

          <template v-if="!unreview">
            <el-table-column
              align="center"
              prop="shopStatus"
              :label="$t('outlet.outletStatus')"
            >
              <template slot-scope="scope">
                <span v-if="scope.row.shopProcessStatus === -1">
                  {{ $t("shopProcess.applyFail") }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 0">{{
                  $t("shopProcess.shopApplication")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 1">{{
                  $t("brand.closed")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 2">{{
                  $t("brand.inOperation")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 3">{{
                  $t("brand.brandOffline")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 4">{{
                  $t("brand.brandOfflineToBeReviewed")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 5">{{
                  $t("brand.platformOffline")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 6">{{
                  $t("brand.platformOfflineToBeReviewed")
                }}</span>
              </template>
            </el-table-column>
          </template>

          <template v-if="unreview">
            <el-table-column
              align="center"
              prop="shopStatus"
              :label="$t('distributionMsg.auditStatus')"
            >
              <template slot-scope="scope">
                <span v-if="scope.row.shopProcessStatus === -1">
                  {{ $t("shopProcess.applyFail") }}</span>
                <span v-if="scope.row.shopProcessStatus === 0">{{
                  $t("shopProcess.storeOpeningApplicationPendingReview")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 1">{{
                  $t("brand.closed")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 2">{{
                  $t("brand.inOperation")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 3">{{
                  $t("brand.brandOffline")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 4">{{
                  $t("brand.brandOfflineToBeReviewed")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 5">{{
                  $t("brand.platformOffline")
                }}</span>
                <span v-else-if="scope.row.shopProcessStatus === 6">{{
                  $t("brand.platformOfflineToBeReviewed")
                }}</span>
              </template>
            </el-table-column>

            <el-table-column
              align="center"
              prop="createTime"
              :label="$t('brand.applicationTime')"
              min-width="100"
            >
            </el-table-column>
          </template>

          <template v-if="!unreview">
            <el-table-column
              align="center"
              prop="auditTime"
              :label="$t('brand.reviewTime')"
              min-width="100"
            >
            </el-table-column>
          </template>
          <el-table-column
            align="center"
            label="门店排序号"
            prop="shopSort"
            width="120"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="餐边码状态"
            prop="tableTop"
            width="150"
            fixed="right"
          >
            <template slot-scope="scope">
              <div style="display: inline-block;margin-right: 10px;">
                {{ scope.row.tableTop == 'OPEN' ? '启用中' : '停用中' }}
              </div>
              <el-switch
                @change="changeTableTopFn(scope.row)"
                v-model="scope.row.tableTop"
                active-value="OPEN"
                inactive-value="CLOSE"
              />
            </template>
          </el-table-column>
          <template v-if="!unreview">
            <el-table-column
              align="center"
              fixed="right"
              :label="$t('publics.operating')"
              width="360"
            >
              <template slot-scope="scope">
                <div class="">
                  <!-- 详情 -->
                  <div
                    v-if="isAuth('platform:station:detail')"
                    class="default-btn text-btn"
                    @click="auditHandle(scope.row.shopId, 0)"
                  >
                    {{ $t("crud.viewTitle") }}
                  </div>
                  <!-- 编辑 -->

                  <!-- <div
                  v-if="isAuth('platform:station:update')"
                  class="default-btn text-btn"
                  @click="auditHandle(scope.row.shopId, 1)"
                >
                  {{ $t("coupon.edit") }}
                </div> -->
                  <!-- 下线门店 -->
                  <div
                    class="default-btn text-btn"
                    v-if="
                      (scope.row.shopProcessStatus === 1 ||
                        scope.row.shopProcessStatus === 2) &&
                      isAuth('platform:station:offline')
                    "
                    @click="offlineHandle(scope.row)"
                  >
                    {{ $t("outlet.offlineOutlet") }}
                  </div>
                  <!-- 下线管理 -->
                  <div
                    class="default-btn text-btn"
                    v-if="
                      (scope.row.shopProcessStatus === -1 ||
                        scope.row.shopProcessStatus === 3 ||
                        scope.row.shopProcessStatus === 4 ||
                        scope.row.shopProcessStatus === 5 ||
                        scope.row.shopProcessStatus === 6) &&
                      isAuth('platform:station:offline')
                    "
                    @click="shopAuditHandle(scope.row.shopId)"
                  >
                    {{
                      scope.row.shopProcessStatus !== 6
                        ? $t("distributionProdLog.offlineManagement")
                        : $t("product.pendingReview")
                    }}
                  </div>
                  <!-- 设为好店 -->
                  <!-- <div
                  v-if="isAuth('platform:station:optimization')"
                  class="default-btn text-btn"
                  @click="outletTypeHandle(scope.row,scope.row.type === 0 ? 1 : 0)"
                >
                  {{
                    scope.row.type === 0
                      ? $t("outlet.setOptimization")
                      : $t("outlet.unselectPreferences")
                  }}
                </div> -->
                  <!-- 编辑门店优选 -->
                  <div
                    class="default-btn text-btn"
                    @click="editStoreSort(scope.row)"
                  >
                    编辑门店优选
                  </div>

                  <!-- 账号管理 -->
                  <div
                    v-if="isAuth('platform:station:accountManagement')"
                    class="default-btn text-btn"
                    @click="shopAccountHandle(scope.row)"
                  >
                    {{ $t("shop.accountManagement") }}
                  </div>
                  <!--
                <div
                  class="default-btn text-btn"
                  @click="deleteHandle(scope.row.shopId)"
                >
                  {{ $t("remindPop.delete") }}
                </div> -->
                </div>
              </template>
            </el-table-column>
          </template>
          <template v-if="unreview">
            <el-table-column
              align="center"
              fixed="right"
              :label="$t('publics.operating')"
              width="300"
            >
              <template slot-scope="scope">
                <div
                  v-if="isAuth('platform:station:detail')"
                  class="default-btn text-btn"
                  @click="auditHandle(scope.row.shopId, 0)"
                >
                  {{ $t("productComm.audit") }}
                </div>
              </template>
            </el-table-column>
          </template>

          <div slot="empty">&nbsp;</div>
        </el-table>
      </div>
      <el-pagination
        v-if="dataList.length"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
      >
      </el-pagination>
    </div>

    <add-or-update
      v-if="addOrUpdateVisible"
      ref="addOrUpdate"
      @refreshDataList="refreshChange"
    ></add-or-update>
    <!-- 下架管理 -->
    <offline-manage
      v-if="offlineDialogVisible"
      ref="offlineData"
      @refreshDataList="refreshChange"
    />
    <!-- 账号管理 -->
    <outletAccount
      v-if="shopAccountVisible"
      ref="shopAccount"
      @refreshDataList="refreshChange"
    ></outletAccount>

    <el-dialog
      title="编辑"
      :visible.sync="dialogFormVisible"
    >
      <el-form
        ref="sortForm"
        :model="currentRowObj"
      >
        <el-form-item
          label="店铺优选"
          required
        >
          <el-radio-group v-model="currentRowObj.type">
            <el-radio :label="1">优选店铺</el-radio>
            <el-radio :label="0">普通店铺</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          label="店铺排序"
          required
        >
          <el-input-number
            size="mini"
            :min="0"
            v-model="currentRowObj.shopSort"
            autocomplete="off"
          ></el-input-number>
        </el-form-item>
      </el-form>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          size="mini"
          @click="dialogFormVisible = false"
        >取 消</el-button>
        <el-button
          type="primary"
          size="mini"
          @click="confirmEditStoreSort"
        >确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import AddOrUpdate from "../auditShop-add-or-update.vue";
import offlineManage from "./outlet-offline-manage.vue";
import outletAccount from "./outlet-account.vue";
import { Debounce } from "@/utils/debounce";
import { convertTimeFormat } from "@/utils";
export default {
  data() {
    return {
      // 图片前缀
      resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
      theData: null, // 保存上次点击查询的请求条件
      theParams: null, // 保存上次点击查询的请求条件
      dataList: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10, // 每页显示多少条
      },
      searchForm: {
        shopStatus: undefined,
        shopProcessStatus: undefined,
        shopName: undefined,
        intro: undefined,
        type: undefined,
        merchantMobile: undefined,
      }, // 搜索
      dateRange: [],
      dataListLoading: false,
      addOrUpdateVisible: false,
      shopAuditVisible: false,
      shopAccountVisible: false,
      shopStatusShow: [
        "",
        this.$i18n.t("shop.inOperation"),
        this.$i18n.t("shop.offlineViolation"),
      ],

      offlineDialogVisible: false,
      allBrandList: [],

      dvyType: [
        {
          value: 1,
          label: this.$i18n.t("order.expressDelivery"),
        },
        {
          value: 2,
          label: this.$i18n.t("order.selfMention"),
        },
        // {
        //   value: 3,
        //   label: this.$i18n.t('order.noNeedRequired')
        // },
        {
          value: 4,
          label: this.$i18n.t("order.sameCityDelivery"),
        },
      ],
      dialogFormVisible: false,
      currentRowObj: {},
    };
  },
  props: {
    tabValue: {
      type: String,
      default: "",
    },
    unreview: {
      type: Boolean,
      default: false,
    },
  },
  components: {
    AddOrUpdate,
    // ShopAudit,
    offlineManage,
    outletAccount,
  },
  created() {
    this.getAllBrandList();
    this.getDataList();
  },
  mounted() { },
  methods: {
    convertTimeFormat,
    newStore() {
      this.$router.push({
        path: "/platform-add-shops/shopProcess",
      });
    },
    changeDateRange(e) {
      if (e) {
        this.searchForm.startSubmitTime = e[0];
        this.searchForm.endSubmitTime = e[1];
      } else {
        delete this.searchForm.startSubmitTime;
        delete this.searchForm.endSubmitTime;
      }
    },
    getAllBrandList() {
      this.$http({
        url: this.$http.adornUrl(`/platform/brandTag/choose-list`),
        method: "get",
      }).then((res) => {
        this.allBrandList = res.data;
      });
    },
    // 删除
    // deleteHandle(id) {
    //   this.$confirm(
    //     this.$i18n.t("remindPop.makeSure") +
    //       " " +
    //       `[${
    //         id
    //           ? this.$i18n.t("remindPop.delete")
    //           : this.$i18n.t("remindPop.batchDeletion")
    //       }]` +
    //       " " +
    //       this.$i18n.t("remindPop.operation") +
    //       "?",
    //     this.$i18n.t("remindPop.remind"),
    //     {
    //       confirmButtonText: this.$i18n.t("remindPop.confirm"),
    //       cancelButtonText: this.$i18n.t("remindPop.cancel"),
    //       type: "warning",
    //     }
    //   )
    //     .then(() => {
    //       this.$http({
    //         url: this.$http.adornUrl(`/platform/shop/${id}`),
    //         method: "delete",
    //         data: this.$http.adornData({}),
    //       }).then(({ data }) => {
    //         this.$message({
    //           message: this.$i18n.t("remindPop.succeeded"),
    //           type: "success",
    //           duration: 1500,
    //           onClose: () => {
    //             this.getDataList(this.page);
    //           },
    //         });
    //       });
    //     })
    //     .catch(() => {});
    // },

    getDataList(page, newData = false) {
      page = page || this.page;
      if (newData || !this.theData) {
        this.theData = {
          current: page.currentPage,
          size: page.pageSize,
        };
        this.theParams = JSON.parse(JSON.stringify(this.searchForm));
      } else {
        this.theData.current = page.currentPage;
        this.theData.size = page.pageSize;
      }

      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl("/platform/shop/pageShop"),
        method: "get",
        params: this.$http.adornParams(
          Object.assign(this.theData, this.theParams, {
            shopBelongs: this.unreviewed ? "2" : "1",
            auditingStatusList: this.unreviewed ? [0, 3] : [-1, 1, 2],
          })
        ),
      }).then(({ data }) => {
        this.dataList = data.records;
        this.page.total = data.total;
        this.page.currentPage = data.current;
        this.dataListLoading = false;
      });
    },
    // 控制开启与关闭餐边码
    changeTableTopFn(row) {
      console.log(row);
      console.log(this.$http.adornParams({
        shopIds: row.shopId,
        tableTop: row.tableTop
      }));
      this.$http({
        url: this.$http.adornUrl("/desktopSetting/renewAllDesktopConfig"),
        method: "get",
        params: this.$http.adornParams({
          shopIds: row.shopId,
          tableTop: row.tableTop
        })
      }).then((res) => {
        if (res.code == '00000') {
          this.$message.success('修改成功')
          this.getDataList(this.page);
        }
      })
    },
    // 停用所有餐边码
    closeAllTableTop() {
      this.$confirm('此操作将关闭全部店铺餐边码功能, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const loading = this.$loading({
          lock: true,
          text: '停用所有店铺餐边码中...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        this.$http({
          url: this.$http.adornUrl("/desktopSetting/renewAllDesktopConfig"),
          method: "get",
          params: this.$http.adornParams({
            tableTop: 'CLOSE'
          })
        }).then((res) => {
          if (res.code == '00000') {
            this.$message.success('关闭成功')
            loading.close()
            this.getDataList(this.page);
          }
        }).catch(() => {
          loading.close()
        })
      })
    },
    // 启用所有店铺餐边码
    openAllTableTop() {

      this.$confirm('此操作将开启全部店铺餐边码功能, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const loading = this.$loading({
          lock: true,
          text: '启用所有店铺餐边码中...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        this.$http({
          url: this.$http.adornUrl("/desktopSetting/renewAllDesktopConfig"),
          method: "get",
          params: this.$http.adornParams({
            tableTop: 'OPEN'
          })
        }).then((res) => {
          if (res.code == '00000') {
            this.$message.success('开启成功')
            loading.close()
            this.getDataList(this.page);
          }
        }).catch(() => {
          loading.close()
        })
      })
    },
    /**
     * 查看 / 审核
     * @param id 门店id
     * @param type 0查看 1编辑
     */
    auditHandle(id, type) {
      // this.addOrUpdateVisible = true
      // this.$nextTick(() => {
      //   this.$refs.addOrUpdate.init(id)
      // })
      if (type === 1) {
        this.$router.push({
          path: "/platform-outlet/auditOutlet-edit",
          query: { shopId: id },
        });
      } else {
        this.$router.push({
          path: "/platform-outlet/auditOutlet-detail",
          query: { shopId: id },
        });
      }
    },
    // 账号管理
    shopAccountHandle(item) {
      this.shopAccountVisible = true;
      this.$nextTick(() => {
        this.$refs.shopAccount.init(item.shopId, item.brandName);
      });
    },
    editStoreSort(row) {
      //编辑优选好店
      this.currentRowObj = { ...row };
      this.dialogFormVisible = true;
    },
    confirmEditStoreSort() {
      if (
        this.currentRowObj.shopSort === undefined ||
        this.currentRowObj.shopSort === null ||
        this.currentRowObj.shopSort === ""
      ) {
        this.$message.warning("请输入排序值");
        return;
      }
      this.outletTypeHandle(this.currentRowObj, this.currentRowObj.type);
    },
    /**
     * 设为好店 / 取消
     * @param row 门店信息
     */
    outletTypeHandle: Debounce(function (row, shopType) {
      this.$http({
        url: this.$http.adornUrl("/platform/shop/updateShopType"),
        method: "put",
        data: this.$http.adornData({
          shopId: row.shopId,
          shopType: shopType,
          sort: row.shopSort,
        }),
      }).then(() => {
        this.$message({
          message: this.$i18n.t("publics.operation"),
          type: "success",
          duration: 1500,
          onClose: () => {
            this.getDataList(this.page);
          },
        });
        this.dialogFormVisible = false;
      });
    }),

    /**
     * 新增店铺
     */
    insertShop() {
      // this.addOrUpdateVisible = true
      // this.$nextTick(() => {
      //   this.$refs.addOrUpdate.init()
      // })
      this.$router.push({ path: "/platform-add-shops/shopProcess" });
    },
    // 下架门店
    offlineHandle(row) {
      // 确定对店铺[' + row.shopName + ']进行下线操作？如是，请填写下线理由
      var tips = this.$i18n.t("outlet.outletTip7");
      tips = tips.replace("SHOPNAME", row.shopName);
      this.$prompt(tips, this.$i18n.t("text.tips"), {
        confirmButtonText: this.$i18n.t("coupon.confirm"),
        cancelButtonText: this.$i18n.t("coupon.cancel"),
        inputPattern: /\s\S+|S+\s|\S/, // 不能全为空格 空字符串
        inputErrorMessage: this.$i18n.t("seckill.offlineReasonTip"),
        inputValidator: (value) => {
          if (value.length > 100) {
            return this.$i18n.t("seckill.offlineReasonTip1");
          }
        },
      }).then((obj) => {
        this.$http({
          url: this.$http.adornUrl(`/platform/shop/offline`),
          method: "post",
          data: this.$http.adornData({
            handleId: row.shopId,
            offlineReason: obj.value || null,
          }),
        }).then(({ data }) => {
          this.$message({
            message: this.$i18n.t("publics.operation"),
            type: "success",
            duration: 1500,
            onClose: () => {
              this.getDataList(this.page);
            },
          });
        });
      });
    },
    /**
     * 刷新回调
     */
    refreshChange() {
      this.getDataList(this.page);
    },
    // 清空自定义数据
    searchReset() {
      this.searchForm = {};
      this.dateRange = [];
    },
    searchChange(newData = false) {
      this.page.currentPage = 1;
      this.getDataList(this.page, newData);
    },
    // 弹窗处理
    shopAuditHandle(id) {
      // this.shopAuditVisible = true
      // this.$nextTick(() => {
      //   this.$refs.shopAudit.init(id)
      // })
      this.getOfflineDetailByShopId(id);
    },

    /**
     * 获取最新店铺下线事件
     */
    getOfflineDetailByShopId(shopId) {
      // api.getEventsOfOfflineStores(shopId).then((data) => {
      //   this.offlineDetail = data
      //   this.$nextTick(() => {
      //     this.$refs.offlineData.init('offlineManage', data)
      //   })
      // })
      this.offlineDialogVisible = true;
      this.$http({
        url: this.$http.adornUrl("/platform/shop/getOfflineByShopId"),
        method: "get",
        params: this.$http.adornParams({
          shopId: shopId,
        }),
      }).then(({ data }) => {
        this.offlineDetail = data;
        this.$nextTick(() => {
          this.$refs.offlineData.init(data);
        });
      });
    },

    /**
     * 获取图片路径
     */
    getImgSrc(img) {
      if (!img) {
        return "";
      }
      if (img.indexOf("http://") === 0 || img.indexOf("https://") === 0) {
        return img;
      }
      return this.resourcesUrl + img;
    },
    /**
     * 当图片加载失败时，切换至默认图
     */
    handlePicError(event) {
      event.target.src = require("@/assets/img/shop-logo-def.png");
    },

    /**
     * 重置表单
     * @param {String} formName 表单名称
     */
    resetSearchForm(formName) {
      this.$refs[formName].resetFields();
      this.searchReset();
    },

    handleSizeChange(val) {
      this.page.pageSize = val;
      this.getDataList();
    },
    handleCurrentChange(val) {
      this.page.currentPage = val;
      this.getDataList();
    },
  },
};
</script>
<style lang="scss" scoped>
.table-con {
  position: relative;
}

.empty-text {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  color: #909399;
}
::v-deep .export-load {
  top: -50% !important;
}
</style>

<style scoped>
>>> .el-table__fixed-right::before {
  z-index: 0;
}
</style>
